//
//  CTimer.m
//  iSudoku
//
//  Created by acumen on 5/24/13.
//  Copyright (c) 2013 Tri Vo. All rights reserved.
//

#import "CTimer.h"

static CTimer *instance = nil;

@implementation CTimer

+ (id)getInstance {
    if (instance == nil) {
        instance = [[CTimer alloc] init];
    }
    return instance;
}

- (id)init {
    self = [super init];
    if (self) {
        // Do something here
        [self resetTime];
    }
    return self;
}


- (void)dealloc {
    [super dealloc];
}

#pragma mark - Class methods

- (void) resetTime {
    _hour = 0;
    _millisecond = 0;
    _second = 0;
    _minute = 0;
}

- (NSString *) getTime {
    NSString *retTime = @"";
    retTime = [NSString stringWithFormat:@"%d :%d :%d", _hour, _minute, _second];
    return retTime;
}

- (void) increaseTime:(ccTime) time {
    _millisecond += time;
    _hour = (_millisecond/3600);
    _minute = (_millisecond/60) - (_hour*60);
    _second = _millisecond - (_hour*3600) - (_minute*60);
}

- (void)decreaseTime:(ccTime)time {
    _millisecond -= time;
    _hour = (_millisecond/3600);
    _minute = (_millisecond/60) - (_hour*60);
    _second = _millisecond - (_hour*3600) - (_minute*60);
}

- (CGFloat) getHour {
    return _hour;
}

- (CGFloat) getMinute {
    return _minute;
}

- (CGFloat) getSecond {
    return _second;
}

- (CGFloat) getMillisecond {
    return _millisecond;
}

- (void) setHour:(CGFloat)hour {
    _hour = hour;
}

- (void) setMinute:(CGFloat)minute {
    _minute = minute;
}

- (void) setSecond:(CGFloat)second {
    _second = second;
}

- (void) setMillisecond:(CGFloat)millisecond {
    _millisecond = millisecond;
}


@end
